home *** CD-ROM | disk | FTP | other *** search
/ A.C.E. 2 / ACE CD 2.iso / FILES / UTILS / AMOSPRO4.DMS / in.adf / Tutorials / Menus / Menus_3.AMOS / Menus_3.amosSourceCode
Encoding:
AMOS Source Code  |  1992-09-28  |  4.0 KB  |  134 lines

  1. '*************************** 
  2. '*    AMOS Professional    * 
  3. '*                         * 
  4. '*         MENUS 3         * 
  5. '*                         *          Automatic Menu selection action
  6. '* (c) Europress Software  * 
  7. '*                         * 
  8. '*     Ronnie Simpson      * 
  9. '*************************** 
  10. '
  11. '------------------------------------------- 
  12. 'When using menus with more than a few options a long list of If...Then
  13. 'statements would be required to cover each possible selection, AMOS 
  14. 'Professional provides 3 instructions to avoid this and easily deal with 
  15. 'even the largest of menus.
  16. '
  17. 'Once this feature is in action automatic menu checking is performed every 
  18. '1/50th. of a second using inturupts and is independant of the rest of the 
  19. 'program.
  20. '
  21. 'For all three versions the following initialisation procedure should be 
  22. 'followed to switch on the automatic system
  23. '
  24. '       Menu$(1)=....     (define your menu or load from bank) 
  25. '       Menu On           (switch on menu) 
  26. '       On Menu......     (define the type of action)  
  27. '       On Menu On        (switch on the automatic checking) 
  28. '
  29. 'The 3 types of action are 
  30. '
  31. '       On Menu Goto...... 
  32. '       On Menu Proc...... 
  33. '       On Menu Gosub..... 
  34. '
  35. 'Each title in your menu is assigned its own label or procedure which is 
  36. 'called automatically each time a selection is made:-  
  37. '
  38. '    On Menu Proc TITLE1,TITLE2,TITLE3.....etc.
  39. '
  40. 'On Menu Proc... causes program control to jump to the procedure defined 
  41. 'in the parameters when an item is selected from the menu, the procedure 
  42. 'can now use the =Choice function to take the required action. 
  43. 'Program control will return to the instruction following the call.
  44. 'Each time a Procedure is entered the automatic system is switched off and 
  45. 'a further call to On Menu On is required before the End Proc to re-activate 
  46. 'the automatic checking. 
  47. '
  48. 'On Menu Gosub... works in exactly the same way with the exception that  
  49. 'procedures are replaced with subroutines. 
  50. 'Each subroutine is defined with its own label and once again On Menu On must
  51. 'be used before the Return instruction to re-activate the automatic checking.
  52. '
  53. 'On Menu Goto.... has been superceeded by the Proc and Gosub versions but  
  54. 'have been included to maintain compatability. 
  55. '
  56. 'If you wish to use more than one set of labels within a program 
  57. 'On Menu Del will erase the list from memory and allow you to define 
  58. 'a new set.
  59. 'Before this can be done the automatic system must be turned off:- 
  60. '
  61. '        On Menu Off 
  62. '        On Menu Del 
  63. '        On Menu Proc FIRST,SECOND....etc. 
  64. '        On Menu On  
  65. '
  66. '------------------------------------------- 
  67. 'WORKING EXAMPLE 
  68. '------------------------------------------- 
  69. '
  70. Dim T$(5)
  71. '
  72. Rem *** tidy up the screen 
  73. '
  74. Screen Open 0,640,200,16,Hires
  75. Palette $0,$F00,$F0,$F,$FF0,$F0F,$FF,$9F9,$7F,$70F,$F07,$333,$666,$999,$CCC,$FFF
  76. Flash Off : Curs Off : Cls 0 : Pen 0 : Paper 7 : Ink 14,0
  77. '
  78. Rem *** set the menu titles
  79. '
  80. Menu$(1)="   CONTROL     "
  81. Menu$(2)="   POINTER SHAPE     "
  82. Menu$(3)="   COLOURS   "
  83. '
  84. Rem *** set the options
  85. '
  86. Menu$(1,1)="    QUIT      "
  87. '
  88. Menu$(2,1)="    POINTER        "
  89. Menu$(2,2)="    CROSS-HAIRS    "
  90. Menu$(2,3)="    CLOCK          "
  91. '
  92. Menu$(3,1)="   RED       "
  93. Menu$(3,2)="   GREEN     "
  94. Menu$(3,3)="   BLUE      "
  95. Menu$(3,4)="   YELLOW    "
  96. Menu$(3,5)="   MAGENTA   "
  97. Menu$(3,6)="   CYAN      "
  98. '
  99. T$(1)="Press right mouse key to see the menu."
  100. T$(2)="Menu control is now independant of the main program."
  101. T$(3)="Each title has its own procedure."
  102. T$(4)="On Menu avoids using too many If...Then statements."
  103. T$(5)="Select CONTROL/QUIT from the menu to return to the editor."
  104. '
  105. Rem *** start the automatic checking 
  106. '
  107. Menu On 
  108. On Menu Proc CONTROL,MOUSE,KOLOURS
  109. On Menu On 
  110. '
  111. Rem *** loop whilst waiting for menu 
  112. '
  113. Do 
  114.    Add COUNT,1,1 To 3000
  115.    If COUNT=500
  116.       Add N,1,1 To 5
  117.       Text 100,N*32,T$(N)
  118.    End If 
  119. Loop 
  120. '
  121. Procedure CONTROL
  122.    Edit 
  123. End Proc
  124. '
  125. Procedure MOUSE
  126.    Change Mouse Choice(2)
  127.    On Menu On 
  128. End Proc
  129. '
  130. Procedure KOLOURS
  131.    Shared T$()
  132.    Ink Choice(2),0
  133.    On Menu On 
  134. End Proc